from condition import Condition
from match_single_condition import filter_single_bar_condition
from okutils import utils

# data = [
#     {'bar': '30m', 'consecutive_bars': 30, 'direction': 1},
#     {'bar': '5m', 'consecutive_bars': 10, 'direction': 1,"recent_three_bars_compare_ema20": False, "three_bars_consecutive":False}
# ]

data = [
    {'bar': '15m', 'consecutive_bars': 30, 'direction': 1},
    # {'bar': '5m', 'consecutive_bars': 10, 'direction': 1, "recent_three_bars_compare_ema20": False, "three_bars_consecutive": True}
]

# 构建对象数组（字典形式），只传递字典中存在的键，利用 Condition 类的默认参数
conditions = [Condition(**d) for d in data]

symbols = utils.get_all_swap()  # 所有
# 遍历conditions
for condition in conditions:
    # 打印conditions 属性值
    print(condition)
    result = filter_single_bar_condition(condition, symbols)
    print("满足条件的数据：", result)

    if len(result) == 0:
        symbols = []
        print("没有满足条件的数据")
        break

    # 合并symbols，和result 取交集
    symbols = list(set(symbols) & set(result))

print("最终symbols：", symbols)
